<template>
  <div ref="div1"  id="div1" @input="inputFn"></div>
</template>

<script>
import E from 'wangeditor'

export default {
  name: 'EditorTemplate',
  data () {
    return {
      editor: null,
      editorData: ''
    }
  },
  created () {
    this.$nextTick(() => {
      this.editor = new E(this.$refs.div1)

      this.editor.config.focus = false
      this.editor.config.height = 200
      this.editor.config.placeholder = ''
      this.editor.config.zIndex = 500
      this.editor.create()
    })
  },
  methods: {
    // 编辑器回显
    appendTxt (value) {
      this.editor.txt.append(value)
    },

    inputFn () {
      // console.log(this.editor.txt.html())
      this.$emit('input', this.editor.txt.html())
    },
    clearTxt () {
      this.editor.txt.clear()
    }
  }
}
</script>

<style scoped>

</style>
